package com.controller;


import com.service.DictionaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class TasksChedule {

    @Autowired
    private DictionaryService dictionaryService;

    //每分钟跑批一次;
    @Scheduled(cron = "0 0/1 * * * ?")
    public void autoUpdateInfo(){
        try {
            dictionaryService.updateDictionaryFromExcel();
            Date date = new Date();
            SimpleDateFormat simpleFormatter = new SimpleDateFormat();
            String format = simpleFormatter.format(date);
            System.out.println("任务调度时间"+format);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
